package org.example.Selenium1;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;
import org.openqa.selenium.interactions.Actions;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;

import javax.swing.*;
import java.time.Duration;

import static java.lang.Thread.sleep;

public class Auto1 {
    public static void main(String[] args) throws InterruptedException {
        //允许所有的请求
        ChromeOptions options = new ChromeOptions();
        options.addArguments("--remote-allow-origins=*");
        //创建一个驱动对象来打开浏览器
        ChromeDriver driver = new ChromeDriver(options);
        driver.get("https://ai-test.hikvision.com/");
        // 立即最大化浏览器窗口
        driver.manage().window().maximize();
        int seconds = 5;
        Duration duration = Duration.ofSeconds(seconds);
        WebDriverWait wait = new WebDriverWait(driver, duration);
        WebElement element = wait.until(ExpectedConditions.elementToBeClickable(By.xpath("//*[@id='header']/div[2]/div[3]/div[1]")));
        element.click();
        sleep(5);
        Actions actions = new Actions(driver);
        actions.moveByOffset(100,100).doubleClick().perform();
        sleep(5);
        driver.findElement(By.xpath("//*[@id=\"tab-1\"]/span")).click();
        sleep(2);
        driver.findElement(By.name("请输入主体账号")).sendKeys("luozhuocai2630");
        driver.findElement(By.name("请输入主体账号")).sendKeys("luozhuocai2630");
        driver.findElement(By.name("请输入主体账号")).sendKeys("luozhuocai2630");
    }

}
